package Day3;

public class Scholar {
    String ClassName;
    String TeacherName;
    String Kai;
    String[] names = new String[30];
    int count = 0;
    public void Show(){
        System.out.println("这是："+ClassName);
        System.out.println("班主任："+TeacherName);
        System.out.println("于"+Kai+"开班");
        System.out.println("学生信息如下：");
        for (int i = 0; i < names.length; i++) {
            if (names[0] == null){
                System.out.println("暂时没有消息");
                break;
            }
            if (names[i] == null){
                System.out.println("");
                break;
            }

            System.out.print(names[i] + " ");
        }
        System.out.println();
    }

    public void add(String newName){
        for (int i = 0; i < names.length; i++) {
            if (names[i] == null) {
                names[i] = newName;
                count++;
                return;
            }
            if (names[i].equals(newName)){
                System.out.println("该名字已存在！");
                return;
            }
        }
        System.out.println("加人失败，没有空位子了");
    }

}
